﻿@model IEnumerable<GTCAS.CommonLib.Entities.GT_MENU>

    @{
        if (Model != null)
        {
        <ul id="menu">
            @{
                var rootMenu = Model.Where(m=>m.PARENT_MENU_ID<=0).ToList();
            }
            @foreach (var item in rootMenu)
            {
            
                <li>
                    <a href="#">@item.MENU_NAME</a>
                    @{
                        var subMenu =  Model.Where(m=>m.PARENT_MENU_ID ==item.MENU_ID).OrderBy(t=>t.ORDINAL).ToList();
                        if (subMenu.Count > 0)
                        {
                            <ul>
                                @foreach (var subItem in subMenu)
                                {
            
                                    <li>
                                        @if(!String.IsNullOrEmpty(subItem.URL)){
                                            <a href="@Url.Content(subItem.URL)">@subItem.MENU_NAME</a>
                                        }
                                        else{
                                            <a href="#">@subItem.MENU_NAME</a>
                                        }
                                    </li>
                                  }

                            </ul>
                        }
                      }

                </li>
            }
               
        </ul>
        }
 }

